HackerRank Construct the Array
解答
code: python
import math
import os
import random
import re
import sys
#
# Complete the 'countArray' function below.
#
# The function is expected to return a LONG_INTEGER.
# The function accepts following parameters:
# 1. INTEGER n
# 2. INTEGER k
# 3. INTEGER x
#
def countArray(n, k, x):
# Return the number of ways to fill in the array.
MOD = 1000000007
for i in range(1, n):
bi = (ai-1 * (k-1) + bi-1 * (k-2)) % MOD if __name__ == '__main__':
first_multiple_input = input().rstrip().split()
n = int(first_multiple_input0) k = int(first_multiple_input1) x = int(first_multiple_input2) answer = countArray(n, k, x)
fptr.write(str(answer) + '\n')
fptr.close()
メモ
https://www.youtube.com/watch?v=_nLeiMMSd4E
bi-1
https://scrapbox.io/files/61d24246effe30001d3a4450.png